/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jule.clases;


/**
 *
 * @author Administrador
 */
public class field {
// int,     int identity 4

//bit -7
//date , smalldatetime 93
//timestamp -2
//varchar, nvarchar 12

//float 8
//money 3
//nchar, uniqueidentifier 1

// bigstring
//ntext, xml -1
//int
//numeric 2
//real 7
//	smallint 5

//tinyint -6
//bigint -5
//decimal 3

    // tipos de campos que aceptamos...
    public enum typeField {
        _int, _string, _bigString, _boolean, _date, _bit, _float, _money, _image, _document, _audio
    };

    private typeField _tipo;

    public typeField getType() {
        return _tipo;
    }

    

    public void setTipo(typeField d) {
        _tipo = d;
    }

    public void setTipo(int tipo) {
        switch (tipo) {
            case 2:
            case 5:
            case -5:
            case 6:
            case 7:
            case 4:
                _tipo = typeField._int;
                break;
            case 12:
                _tipo = typeField._string;
                break;
            case -1: //ntext or xml
                _tipo = typeField._bigString;
                break;
            case 91:
            case -2: // este no esta claro, es un timestamp...
            case 93:
                _tipo = typeField._date;
                break;
            case -7: //bit
                _tipo = typeField._boolean;
                break;
            case 8:
            case 3:
                _tipo = typeField._float;
                break;

            default:
                _tipo = typeField._string;
                break;

        }
    }


    private typeField targetType;
   // public static final String PROP_TARGETTYPE = "_targetType";

    /**
     * Get the value of targetType
     *
     * @return the value of targetType
     */
    public typeField getTargetType() {
        return targetType;
    }


     
    /**
     * Set the value of targetType
     *
     * @param targetType new value of targetType
     */
    public void setTargetType(typeField targetType) {
        this.targetType = targetType;
    }


//    public int getTargetTypeAsInt() {
//        switch (targetType) {
//            case _int:
//                return 4;
//            case _string:
//                return 12;
//            case _bigString: //ntext or xml
//                return -1;
//            case _date:
//                return 93;
//            case _boolean: //bit
//                return -7;
//            case _float:
//                return 3;
//
//            default:
//                return 12;
//        }
//    }
//
      public void setTargetType(int tipo) {
         switch (tipo) {
            case 2:
            case 5:
            case -5:
            case 6:
            case 7:
            case 4:
                targetType = typeField._int;
                break;
            case 12:
                targetType = typeField._string;
                break;
            case -1: //ntext or xml
                targetType = typeField._bigString;
                break;
            case 91:
            case -2: // este no esta claro, es un timestamp...
            case 93:
                targetType = typeField._date;
                break;
            case -7: //bit
                targetType = typeField._boolean;
                break;
            case 8:
            case 3:
                targetType = typeField._float;
                break;

            default:
                targetType = typeField._string;
                break;

        }
    }



    private String _nombre;

    public String getNombre() {
        return _nombre;
    }

    public void setNombre(String d) {
        _nombre = d;
    }    // name in the generated scripts....
    protected String targetName;

    /**
     * Get the value of targetName
     *
     * @return the value of targetName
     */
    public String getTargetName() {
        return targetName;
    }

    /**
     * Set the value of targetName
     *
     * @param targetName new value of targetName
     */
    public void setTargetName(String targetName) {
        this.targetName = targetName;
    }

    public static int tipo(String type) {
        if (type == "string") {
            return 1;
        }

        return 1;
    }
    private boolean _selected;

    public Boolean getSelected() {
        return _selected;
    }

    public void setSelected(Boolean d) {
        _selected = d;
    }
    private boolean _isKey;

    public boolean getisKey() {
        return _isKey;
    }

    public void setisKey(boolean d) {
        _isKey = d;
    }
    private Boolean _isForeignKey;

    public Boolean getisForeignKey() {
        if (_isForeignKey == null) {
            return false;
        } else {
            return _isForeignKey;
        }

    }

    public void setisForeignKey(Boolean d) {
        _isForeignKey = d;
    }

    @Override
    public String toString() {
        return this.getNombre();
    }
    private boolean AllowNulls;

    /**
     * Get the value of notNull
     *
     * @return the value of notNull
     */
    public boolean allowNulls() {
        return AllowNulls;
    }

    /**
     * Set the value of notNull
     *
     * @param notNull new value of notNull
     */
    public void setAllowNulls(boolean notNull) {
        this.AllowNulls = notNull;
    }
    private boolean autoIncrement;

    /**
     * Get the value of autoIncrement
     *
     * @return the value of autoIncrement
     */
    public boolean isAutoIncrement() {
        return autoIncrement;
    }

    /**
     * Set the value of autoIncrement
     *
     * @param autoIncrement new value of autoIncrement
     */
    public void setAutoIncrement(boolean autoIncrement) {
        this.autoIncrement = autoIncrement;
    }
    private String _defaultValue;

    /**
     * Get the value of defaultValue
     *
     * @return the value of defaultValue
     */
    public String getDefaultValue() {
        return _defaultValue;
    }

    /**
     * Set the value of defaultValue
     *
     * @param defaultValue new value of defaultValue
     */
    public void setDefaultValue(String defaultValue) {
        this._defaultValue = defaultValue;
    }
    private int size;

    /**
     * Get the value of size
     *
     * @return the value of size
     */
    public long getSize() {
        return size;
    }

    /**
     * Set the value of size
     *
     * @param size new value of size
     */
    public void setSize(int size) {
        this.size = size;
    }
    protected String comment;

    /**
     * Get the value of comment
     *
     * @return the value of comment
     */
    public String getComment() {
        return comment;
    }

    /**
     * Set the value of comment
     *
     * @param comment new value of comment
     */
    public void setComment(String comment) {
        this.comment = comment;
    }

    protected String quoted;

    /**
     * Get the value of finalName
     *
     * @return the value of finalName
     */
    public String getQuoted() {
        return quoted;
    }

    /**
     * Set the value of finalName
     *
     * @param finalName new value of finalName
     */
    public void setQuoted(String quoted) {
        this.quoted = quoted;
    }
}
